<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学习vue</title>
    <script src="../js/vue.js"></script>
    <style>
        *{
            padding: 12px;
        }
    </style>
</head>
<body>
    <div id="root">
    </div>
    <script>
        Vue.config.productionTip = false
        let data = {
            name : 'f1',
            address: 'bb'
        }
        const obs = new Observer(data)
        let vm ={}
        vm._data = data = obs

        function Observer(obj){
            const keys = Object.keys(data)
            keys.forEach((k)=>{
                Object.defineProperty(this,k,{
                    get(){
                        return obj[k]
                    },
                    set(newValue){
                        //在这里可以解析模板，生成虚拟dom，比较虚拟dom，生成真实dom
                        obj[k] = newValue
                    }
                })
            })
        }
    </script>    
</body>
</html>